<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
</head>

<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <div class="layui-inline">
        <div class="layui-input-inline">
            <input type="text" value="" placeholder="关键字" class="layui-input search_input" id="sSearchKey">
        </div>

        <div class="layui-inline">
            <div class="layui-input-inline" style="height: 38px;">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <select name="modules" lay-verify="required" id="status">
                            <option value="">状态</option>
                            <option value="">不限</option>
                            <option value="0">上架</option>
                            <option value="-1">下架</option>
                        </select>
                    </div>
                </form>
            </div>
        </div>

        <div class="layui-inline">
            <div class="layui-input-inline" style="height: 38px;">
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <select name="modules" lay-verify="required" id="goodsType">
                            <option value="">类型</option>
                            <option value="">不限</option>
                            <option value="1">保税区</option>
                            <option value="2">大贸区</option>
                        </select>
                    </div>
                </form>
            </div>
        </div>

        <div class="layui-input-inline">
            <input class="layui-input" placeholder="开始日" id="startTime">
        </div>

        <div class="layui-input-inline">
            <input class="layui-input" placeholder="截止日" id="endTime">
        </div>

    </div>
    <a class="layui-btn layui-btn-primary" id="search"><i class="layui-icon">&#xe615;</i>查询</a>
    </div>
</blockquote>

<div class="left_list">


    <div class="layui-inline">
        <a class="layui-btn layui-btn-danger news_del" onclick="changeListItem(2)">选择</a>
    </div>
</div>
<form action="" class="layui-form table-box">

    <div id="listView"></div>
    <div id="laypage" class="laypage"></div>

</form>

<input id="mid" value="" type="hidden"/>
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/js/time.js"></script>
<script src="/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/common.js" type="text/javascript" charset="utf-8"></script>
<script id="tmpList" type="text/html">

    <table class="layui-table" lay-even lay-skin="row">
        <thead>
        <tr>
            <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
            <th>id</th>
            <th>封面图</th>
            <th>sku</th>
            <th>标题</th>
            <th>类型</th>
            <th>税费</th>
            <th>原价</th>
            <th>状态</th>
            <th>总销量</th>
            <th>库存</th>
            <th>所属分类</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {{# layui.each(d.list, function(index, item){ }}

        <tr>
            <td><input type="checkbox" value="{{ item.id }}" name="" lay-skin="primary"></td>
            <td>{{#if (item.id!=null) {}}
                {{ item.id }}
                {{#}}}
            </td>
            <td>
                <img src="{{ item.facePhoto }}">
            </td>
            <td>{{#if (item.sku!=null) {}}
                {{ item.sku }}
                {{#}}}
            </td>
            <td>{{#if (item.title!=null) {}}
                {{ item.title }}
                {{#}}}
            </td>
            <td>{{#if (item.goodsType==1) {}}
                保税区
                {{#}}}
                {{#if (item.goodsType==2) {}}
                大贸区
                {{#}}}
            </td>
            <td>{{#if (item.taxPrice!=null) {}}
                {{ item.taxPrice }}
                {{#}}}
            </td>
            <td>{{#if (item.originalPrice!=null) {}}
                {{ item.originalPrice }}
                {{#}}}
            </td>
            <td>{{#if (item.status == 0) {}}
                上架
                {{#} else {}}
               下架
                {{#}}}
            </td>
            <td>{{#if (item.saleNum!=null) {}}
                {{ item.saleNum }}
                {{#}}}
            </td>
            <td>{{#if (item.kucun!=null) {}}
                {{ item.kucun }}
                {{#}}}
            </td>
            <td>{{#if (item.className!=null) {}}
                {{ item.className }}
                {{#}}}
            </td>
            <td>{{formatDate(item.createTime)}}</td>
            <td>
                <a class="layui-btn layui-btn-mini news_details" onclick=detail({{item.id}})><i class="layui-icon">
                    &#xe642;</i>选择</a>
            </td>
        </tr>
        {{# }); }} {{# if(d.list.length === 0){ }}
        <td colspan="10" align="center">无数据</td>
        {{# } }}
        </tbody>
    </table>
</script>

<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //开始时间
        laydate.render({
            elem: '#startTime'
        });
        //结束时间
        laydate.render({
            elem: '#endTime'
        });
    });


    //批量操作
    function changeListItem(PL) {
        var box = $("input[lay-filter='allChoose']").prop("checked");
        var child = $("input[lay-filter='allChoose']").parents('table').find('tbody tr td:first-child input[type="checkbox"]:checked');
        var valueList = [];
        for (var i = 0; i < child.length; i++) {
            var item = parseInt(child.eq(i).attr("value"));
            valueList.push(item);
        }
        switch (PL) {
            default:
                selectAll(valueList);
                break;
        }

    }

    //批量删除
    function selectAll(Items) { //obj=整条数据行
        parent.getGoods(Items);
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }

    var searchData = {};
    $(document).ready(function () {

        $("#search").click(function () {
            searchData = {
                startTime: $('#startTime').val(),
                status: $('#status').val(),
                goodsType: $('#goodsType').val(),
                endTime: $('#endTime').val(),
                searchKey: $('#sSearchKey').val()
            };
            getList({});
        });
        getList({});
    });

    function getList(data) {
        data = searchData;
        CommonLoadList("/goods/list", data, page, "tmpList", "listView", "laypage");
    }

    function detail(id) {
        var valueList = [];
        valueList.push(id);
        selectAll(valueList)
    }


</script>
</body>
</html>